package com.mapler.tbot.service;

import com.mapler.tbot.service.TimeoutThread;
import org.openqa.selenium.firefox.FirefoxDriver;
import org.openqa.selenium.ie.InternetExplorerDriver;
import org.openqa.selenium.WebDriver;

public class TimeoutUrl {

    private static WebDriver driver;

    public static void main(String[] args) throws Exception {

        String url = "http://www.kinopoisk.ru/";

        driver = new FirefoxDriver();

        TimeoutThread timeoutThread = new TimeoutThread(5);
        timeoutThread.start();

        driver.get(url);
        timeoutThread.interrupt();

        Throwable e = ThreadReturn.get(timeoutThread.getName());
        if (e != null) {
            System.out.println("Timed out: " + e.getMessage());
        } else {
            System.out.println("No timeout");
        }

        driver.close();

        System.exit(0);
    }
}